package com.shujia.flink.tf

import org.apache.flink.api.common.functions.FilterFunction
import org.apache.flink.streaming.api.scala._

object Demo3Filter {
  def main(args: Array[String]): Unit = {

    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment


    val listDS: DataStream[Int] = env.fromCollection(List(1, 2, 3, 4, 5, 6, 7, 8, 9))


    //scala api
    val filterDS: DataStream[Int] = listDS.filter(i => i % 2 == 1)

    //java api
    val javaFilterDS: DataStream[Int] = listDS.filter(new FilterFunction[Int] {
      override def filter(value: Int): Boolean = {
        value % 2 == 1
      }
    })

    javaFilterDS.print()

    env.execute()
  }
}
